﻿
namespace Canal.UserServiceSync.CanalSyncService
{

    /// <summary>
    /// 数据同步Host服务
    /// </summary>
    public class UserInfoSyncHostService : IHostedService
    {
        private readonly UserInfoSync _userInfoSync;

        /// <summary>
        /// 使用Host服务实现任务自动执行
        /// </summary>
        /// <param name="userInfoSync"></param>
        public UserInfoSyncHostService(UserInfoSync userInfoSync)
        {
            _userInfoSync = userInfoSync;
        }

        /// <summary>
        /// 开始执行
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task StartAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("UserInfo同步任务开始...");
            _userInfoSync.Start();
            return Task.CompletedTask;
        }

        /// <summary>
        /// 任务停止
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task StopAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("UserInfo同步任务停止...");
            throw new NotImplementedException();
        }
    }
}
